package com.leyou.cart.config;

import com.leyou.auth.utils.RsaUtils;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;

import javax.annotation.PostConstruct;
import java.security.PublicKey;

@Data
@ConfigurationProperties("ly.jwt")
public class JwtProperties {


    private String pubKeyPath;
    private String cookieName;


    //类对象实例化后，就应该读取公钥和私钥
    private PublicKey  publicKey;

    @PostConstruct   // 等效为 bean标签中的init-method属性
    public void init() throws Exception {
            this.publicKey = RsaUtils.getPublicKey(pubKeyPath);
    }
}
